package org.jeecg.common.util;

import org.jeecg.common.exception.JeecgBootException;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.util.Objects;

public class RequestUtil {

    /**
     * 获取Post请求参数
     *  @param req HttpServletRequest 请求对象
     * @return
     */
    public static String getPostParam(HttpServletRequest req) {
        String line = null;
        try {
            BufferedReader reader = req.getReader();
            do {
                line = reader.readLine();
            }
            while (Objects.isNull(line));
            return line;
        } catch (IOException e) {
            throw new JeecgBootException("读取post请求参数失败！");
        }
    }
}
